﻿using System.Web.Security;

namespace NMA.Web.Areas.Admin.Models.Service.Impl
{
    using NMA.Infrastructure.DBC;

    public class AccountMembershipService : IMembershipService
    {
        private readonly MembershipProvider _provider;

        public AccountMembershipService()
            : this(null)
        {
            //_provider = Membership.Provider;
        }

        public AccountMembershipService(MembershipProvider provider)
        {
            _provider = provider ?? Membership.Provider;
        }

        public int MinPasswordLength
        {
            get
            {
                return _provider.MinRequiredPasswordLength;
            }
        }

        public bool ValidateUser(string userName, string password)
        {
            Check.Assert(string.IsNullOrEmpty(userName) != true, "Username is null or empty");
            Check.Assert(string.IsNullOrEmpty(password) != true, "Password is null or empty");

            return _provider.ValidateUser(userName, password);
        }  
    }
}